<template>
  <div class="">
    <div class="box">
      <div v-for="item in list" :key="item.id">
        <div class="img">
          <img width="150px" height="140px" :src="item.picUrl" alt="" />
        </div>
        <p>{{ item.name }}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'sing',
  data() {
    return {
      list: [],
    }
  },
  methods: {
    async getdata() {
      if (this.list == '') {
        const { data: res } = await this.$http.get(
          `/cloudsearch?keywords=${this.$store.state.search.searchName}&type=100`
        )
        if (res.code !== 200) return this.$message.success('搜索失败')
        this.list = res.result.artists
       this.$store.commit('search/getsongCount',res.result.artistCount)  //多少条歌曲传递到 vuex

      }
    },
  },
  created() {
    this.getdata()
    this.$store.commit('search/getsearchlist', this.$route.meta.title)
  },
}
</script>

<style scoped lang="less">
.box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin: 20px 0;
  .img {
    margin-right: 20px;
  }
  p {
    font-size: 0.8rem;
    color: #0c73c2;
  }
}
</style>